<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>highlight.js</title>
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (JavaScript) - Theme (Breeze Dark)"/>
</head><body style="background-color:#232629;color:#cfcfc2"><pre>
<span style="color:#7a7c7d;">#! shebang</span>
#! no-shebang

<span style="color:#7a7c7d;">/* comment */</span>

<span style="font-weight:bold;">function</span> <span style="color:#8e44ad;">fun</span>()
{
    <span style="font-weight:bold;">var</span> boo = { <span style="color:#f44f4f;">'key'</span>: [ <span style="color:#f67400;">1</span>, <span style="color:#f67400;">2.0</span>, <span style="color:#f67400;">3.0e1</span>, <span style="color:#f67400;">004</span>, <span style="color:#f67400;">0x5</span> ] };
}

<span style="font-weight:bold;font-style:italic;">class</span> MyClass; <span style="color:#7a7c7d;">// reserved keywords</span>

<span style="color:#7a7c7d;">// Member objects: text after &quot;.&quot;</span>
object.<span style="color:#2980b9;">property</span> <span style="font-weight:bold;">instanceof</span> <span style="color:#7f8c8d;">Number</span>;
iden1.<span style="color:#2980b9;">iden2</span>  . <span style="color:#2980b9;">iden3</span>.<span style="color:#2980b9;">class</span> <span style="font-weight:bold;font-style:italic;">class</span>;

<span style="font-weight:bold;">var</span> escapes = <span style="color:#f44f4f;">&quot;aa</span><span style="color:#3daee9;">\</span><span style="color:#3daee9;font-weight:bold;">b</span><span style="color:#3daee9;">\</span><span style="color:#3daee9;font-weight:bold;">n</span><span style="color:#3daee9;">\</span><span style="color:#3daee9;font-weight:bold;">0</span><span style="color:#f44f4f;">a</span><span style="color:#3daee9;">\&quot;</span><span style="color:#f44f4f;">a</span><span style="color:#3daee9;">\x12</span><span style="color:#f44f4f;">a</span><span style="color:#3daee9;">\32</span><span style="color:#f44f4f;">a</span><span style="color:#3daee9;">\u{123}</span><span style="color:#f44f4f;">a</span><span style="color:#3daee9;">\$\%\ \#\y\a</span><span style="color:#f44f4f;">aa</span><span style="color:#3daee9;">\</span>
<span style="color:#f44f4f;">aaa&quot;</span>;
<span style="font-weight:bold;">var</span> octal = <span style="color:#f67400;">0o124</span>;
<span style="font-weight:bold;">var</span> bin = <span style="color:#f67400;">0b1010</span>;

<span style="color:#8e44ad;">日本語</span>().<span style="color:#2980b9;">ლಠ益ಠლ</span>.<span style="color:#2980b9;">ñá</span> = <span style="color:#f67400;">42</span>;
δ /No-Regex/

<span style="color:#7a7c7d;">// Only highlight valid regular expressions, of a single line, after strings</span>
<span style="color:#7a7c7d;">// See: https://github.com/microsoft/TypeScript-TmLanguage/issues/786</span>
<span style="color:#f44f4f;">&quot;text&quot;</span> /No-Regex
<span style="color:#f44f4f;">&quot;text&quot;</span> <span style="color:#da4453;">/Regex</span><span style="color:#3daee9;">[:)]</span><span style="color:#3daee9;">*</span><span style="color:#da4453;">/</span>;
<span style="font-weight:bold;">const</span> a = <span style="color:#f44f4f;">&quot;6&quot;</span> / <span style="color:#f67400;">2</span>; <span style="color:#7a7c7d;">/*comment*/</span> <span style="font-weight:bold;">const</span> b = <span style="color:#f67400;">5</span>;
<span style="color:#7f8c8d;">console</span>.<span style="color:#8e44ad;font-style:italic;">log</span>(<span style="color:#f44f4f;">&quot;4&quot;</span> / <span style="color:#f44f4f;">&quot;2&quot;</span>); <span style="color:#7a7c7d;">// 2</span>
<span style="color:#7a7c7d;">// Single quote</span>
<span style="font-weight:bold;">const</span> a = <span style="color:#f44f4f;">'6'</span> / <span style="color:#f67400;">2</span>; <span style="color:#7a7c7d;">/*comment*/</span> <span style="font-weight:bold;">const</span> b = <span style="color:#f67400;">5</span>;
<span style="color:#7f8c8d;">console</span>.<span style="color:#8e44ad;font-style:italic;">log</span>(<span style="color:#f44f4f;">'4'</span> / <span style="color:#f44f4f;">'2'</span>); <span style="color:#7a7c7d;">// 2</span>
<span style="color:#7a7c7d;">// Template</span>
<span style="font-weight:bold;">const</span> a = <span style="color:#da4453;">`6`</span> / <span style="color:#f67400;">2</span>; <span style="color:#7a7c7d;">/*comment*/</span> <span style="font-weight:bold;">const</span> b = <span style="color:#f67400;">5</span>;
<span style="color:#7f8c8d;">console</span>.<span style="color:#8e44ad;font-style:italic;">log</span>(<span style="color:#da4453;">`4`</span> / <span style="color:#da4453;">`2`</span>); <span style="color:#7a7c7d;">// 2</span>

<span style="color:#7a7c7d;">// Built-in</span>
<span style="font-weight:bold;">const</span> os = <span style="color:#27ae60;">require</span>(<span style="color:#f44f4f;">'os'</span>);
<span style="color:#7f8c8d;">JSON</span>.<span style="color:#8e44ad;font-style:italic;">stringify</span>(<span style="color:#f44f4f;">&quot;hello&quot;</span>);
<span style="color:#7f8c8d;">console</span>.<span style="color:#8e44ad;font-style:italic;">error</span>(<span style="color:#f44f4f;">&quot;hello&quot;</span>);
<span style="color:#7f8c8d;">Math</span>.<span style="color:#27aeae;font-weight:bold;">LOG10E</span>;
<span style="color:#7f8c8d;">Number</span>.<span style="color:#27aeae;font-weight:bold;">MAX_SAFE_INTEGER</span>;
<span style="color:#7f8c8d;">String</span>.<span style="color:#8e44ad;">raw</span><span style="color:#da4453;">`raw text \.\n${}`</span>

<span style="color:#7a7c7d;">// Tagged template literals</span>
<span style="color:#8e44ad;">tagFunc</span><span style="color:#da4453;">`</span>
<span style="color:#da4453;">    Hello world!</span>
<span style="color:#da4453;">    </span><span style="color:#3daee9;">${</span> <span style="color:#8e44ad;">alert</span>(<span style="color:#f44f4f;">&quot;Hello!&quot;</span>); <span style="color:#3daee9;">}</span><span style="color:#da4453;">`</span>;
obj.<span style="color:#2980b9;">something</span>.<span style="color:#8e44ad;">tagFunc</span><span style="color:#da4453;">`Setting </span><span style="color:#3daee9;">${</span>setting<span style="color:#3daee9;">}</span><span style="color:#da4453;"> is </span><span style="color:#3daee9;">${</span>value + <span style="color:#f67400;">5</span><span style="color:#3daee9;">}</span><span style="color:#da4453;">!`</span>;

<span style="color:#7a7c7d;">/* </span>
<span style="color:#7a7c7d;">   </span><span style="color:#81ca2d;background-color:#4d1f24;font-weight:bold;">NOTE</span><span style="color:#7a7c7d;">: The words &quot;todo&quot;, &quot;fixme&quot; and &quot;note&quot; should be rendered in a different style</span>
<span style="color:#7a7c7d;">   within comments, match should be caseless (to test for regexp insensitive attribute).</span>
<span style="color:#7a7c7d;">   The regex used for this rule is */</span>
   <span style="color:#7f8c8d;">String</span> = <span style="color:#da4453;">/</span><span style="color:#3daee9;">\b(?</span><span style="color:#da4453;">:fixme</span><span style="color:#3daee9;">|</span><span style="color:#da4453;">todo</span><span style="color:#3daee9;">|</span><span style="color:#da4453;">note</span><span style="color:#3daee9;">)\b</span><span style="color:#da4453;">/</span>
   <span style="color:#7a7c7d;">/* Thus,  for example &quot;Notebook&quot; is not caught by</span>
<span style="color:#7a7c7d;">   this rule. (the &quot;?:&quot; in the subpattern is there to avoid the regex engine wasting time</span>
<span style="color:#7a7c7d;">   saving a backref, which is not used for anything. I do not know if the overhead of parsing</span>
<span style="color:#7a7c7d;">   that is greater than the time saved by not capturing the text...)</span>
<span style="color:#7a7c7d;">   The rule for catching these words is placed in a context &quot;Comment common&quot;, which is used</span>
<span style="color:#7a7c7d;">   by both comment contexts (single line, multiline) using the new &quot;IncludeRules&quot; item.</span>
<span style="color:#7a7c7d;">*/</span>

<span style="color:#7a7c7d;">// test if regex support works - nice with new fallthrough prop in context:)</span>
somestring.<span style="color:#8e44ad;">replace</span>( <span style="color:#da4453;">/dooh/</span> , <span style="color:#f44f4f;">&quot;bah!&quot;</span>);
re=<span style="color:#da4453;">/foo/ig</span>; <span style="color:#7a7c7d;">// hehe</span>

somestring.<span style="color:#8e44ad;">search</span>(
       <span style="color:#da4453;">/</span><span style="color:#3daee9;">^</span><span style="color:#da4453;">foo</span><span style="color:#3daee9;">\w</span><span style="color:#3daee9;">+</span><span style="color:#3daee9;">\s\d</span><span style="color:#3daee9;">{0,15}$</span><span style="color:#da4453;">/</span>
                  );

        re =
        <span style="color:#da4453;">/dooh/</span>;

<span style="color:#7a7c7d;">// This is supposedly legal:</span>
re = somebool ? <span style="color:#da4453;">/foo/</span> : <span style="color:#da4453;">/bar/</span>;

<span style="color:#7a7c7d;">// </span><span style="color:#81ca2d;background-color:#4d1f24;font-weight:bold;">NOTE</span><span style="color:#7a7c7d;"> - Special case: an empty regex, not a comment.</span>
<span style="color:#7a7c7d;">// The rule uses a positive lookahead assertion to catch it: &quot;//(?=;)&quot;.</span>
re = <span style="color:#7a7c7d;">//;</span>
re = <span style="color:#da4453;">/a</span><span style="color:#3daee9;">|</span><span style="color:#da4453;">b/</span>;

<span style="color:#7a7c7d;">/*</span>
<span style="color:#7a7c7d;">   Tests for the regex parser.</span>
<span style="color:#7a7c7d;">   It will parse classes, quanitfiers, special characters and regex operaters,</span>
<span style="color:#7a7c7d;">   as specified in the netscape documentation for javascript.</span>
<span style="color:#7a7c7d;">   Regexps are only parsed in their clean form, as the RegExp(string) constructor</span>
<span style="color:#7a7c7d;">   is using a quoted string.</span>
<span style="color:#7a7c7d;">   </span><span style="color:#ca9219;background-color:#451e1a;font-weight:bold;">TODO</span><span style="color:#7a7c7d;">: Find out if more regex feats should be supported.</span>
<span style="color:#7a7c7d;">         Consider using more itemDatas - assertion, quantifier are options.</span>
<span style="color:#7a7c7d;">*/</span>

re = <span style="color:#da4453;">/</span><span style="color:#3daee9;">^</span><span style="color:#da4453;">text</span><span style="color:#3daee9;">\s</span><span style="color:#3daee9;">+</span><span style="color:#3daee9;">\d</span><span style="color:#3daee9;">+</span><span style="color:#3daee9;">\s</span><span style="color:#3daee9;">*$</span><span style="color:#da4453;">/</span>;
re = <span style="color:#da4453;">/a pattern with caret </span><span style="color:#3daee9;">\(</span><span style="color:#da4453;">^</span><span style="color:#3daee9;">\)</span><span style="color:#da4453;"> in it/</span>;
re = <span style="color:#da4453;">/</span><span style="color:#3daee9;">(</span><span style="color:#3daee9;">\d</span><span style="color:#3daee9;">{0,4})</span><span style="color:#3daee9;">\D</span><span style="color:#da4453;">/</span>;
re = <span style="color:#da4453;">/</span><span style="color:#3daee9;">[a-zA-Z_]</span><span style="color:#3daee9;">+</span><span style="color:#da4453;">/</span>;
re = <span style="color:#da4453;">/</span><span style="color:#3daee9;">[</span><span style="color:#3daee9;">^\d</span><span style="color:#3daee9;">^]</span><span style="color:#3daee9;">+</span><span style="color:#da4453;">/</span>;
re = <span style="color:#da4453;">/</span><span style="color:#3daee9;">\s</span><span style="color:#3daee9;">+?</span><span style="color:#3daee9;">\w</span><span style="color:#3daee9;">+\.$</span><span style="color:#da4453;">/</span>;
re = <span style="color:#da4453;">/</span><span style="color:#3daee9;">\/\/</span><span style="color:#da4453;">/</span>;
re = <span style="color:#da4453;">/a</span><span style="color:#3daee9;">|</span><span style="color:#da4453;">b/</span>;

<span style="color:#7a7c7d;">// the following are not regexps in E4X (=xml embedded into JavaScript)</span>
<span style="font-weight:bold;">var</span> p = &lt;p&gt;Hello World&lt;/p&gt;
<span style="font-weight:bold;">var</span> p = <span style="color:#da4453;">/&lt;/</span>
<span style="font-weight:bold;">var</span> p = /&gt;/

<span style="color:#7a7c7d;">// a test if #pop back from a comment will work</span>
re = <span style="color:#7a7c7d;">/*/foo/*/</span> <span style="color:#da4453;">/bar/</span>;
<span style="color:#7a7c7d;">//           ^ POP</span>
<span style="color:#7a7c7d;">//             ^ we got back after pop in comment, if there is regexp attribs here :-)</span>

<span style="color:#7a7c7d;">/*</span>
<span style="color:#7a7c7d;">   Some tests if the fallthrough works.</span>
<span style="color:#7a7c7d;">   The fallthrough happens if a regexp is not found in a possible (!) position,</span>
<span style="color:#7a7c7d;">   which is after &quot;search(&quot; or &quot;replace(&quot; or &quot;=&quot; or &quot;?&quot; or &quot;:&quot; in version 0.1 of the xml file</span>
<span style="color:#7a7c7d;">*/</span>

<span style="font-weight:bold;">var</span> foo = <span style="color:#f44f4f;">'bar'</span>;
<span style="color:#7a7c7d;">//        ^ fallthrough!</span>


somestring.<span style="color:#8e44ad;">replace</span>( <span style="font-weight:bold;">new</span> <span style="color:#7f8c8d;">RegExp</span>(<span style="color:#f44f4f;">&quot;</span><span style="color:#3daee9;">\\</span><span style="color:#f44f4f;">b</span><span style="color:#3daee9;">\\</span><span style="color:#f44f4f;">w+</span><span style="color:#3daee9;">\\</span><span style="color:#f44f4f;">b&quot;</span>), <span style="color:#f44f4f;">&quot;word: $1&quot;</span>);
<span style="color:#7a7c7d;">//                  ^ fallthrough expected. (&quot;new&quot; whould be bold)</span>


something.<span style="color:#2980b9;">method</span> =
    <span style="font-weight:bold;">function</span> ( a, b, c ) { <span style="color:#7a7c7d;">/* ... */</span> }
<span style="color:#7a7c7d;">//  ^ fallthrough ?!</span>

something.<span style="color:#2980b9;">other</span> =
<span style="font-weight:bold;">function</span> ( d, e, f ) { <span style="color:#7a7c7d;">/* ... */</span> }
<span style="color:#7a7c7d;">// fallthrough expected at col 0 (&quot;function&quot; should be bold)</span>

<span style="font-weight:bold;">var</span> ary = <span style="font-weight:bold;">new</span> <span style="color:#7f8c8d;">Array</span>(<span style="color:#f67400;">5</span>);
<span style="color:#7a7c7d;">//        ^ fallthrough ? (if keyword is correctly rendered)</span>

<span style="font-weight:bold;">var</span> b = a ? <span style="color:#f67400;">1</span> : <span style="color:#f67400;">0</span>;
<span style="color:#7a7c7d;">//          ^   ^ fallthroughs. numbers must be rendered correctly.</span>

<span style="font-weight:bold;">var</span> c = d ? <span style="font-weight:bold;">true</span> : <span style="font-weight:bold;">false</span>;

<span style="font-weight:bold;">var</span> conditinalstring = b ?
  <span style="color:#f44f4f;">&quot;something&quot;</span> :
  <span style="color:#f44f4f;">&quot;something else&quot;</span>;
<span style="color:#7a7c7d;">// guess...</span>


<span style="color:#7a7c7d;">/*</span>
<span style="color:#7a7c7d;">   Normal program flow...</span>
<span style="color:#7a7c7d;">*/</span>

<span style="color:#fdbc4b;font-weight:bold;">if</span> (something)
  <span style="color:#8e44ad;">dostuff</span>();
<span style="color:#fdbc4b;font-weight:bold;">else</span>
  <span style="color:#8e44ad;">dont</span>();

  <span style="color:#fdbc4b;font-weight:bold;">return</span>;

<span style="color:#fdbc4b;font-weight:bold;">try</span> { <span style="color:#8e44ad;">bla</span>() } <span style="color:#fdbc4b;font-weight:bold;">catch</span> (e) { <span style="color:#8e44ad;">alert</span>(<span style="color:#f44f4f;">&quot;ERROR! : &quot;</span> + e) }

<span style="color:#fdbc4b;font-weight:bold;">for</span> (int i=<span style="color:#f67400;">0</span>; i &lt; j; i++)
  <span style="color:#7f8c8d;">document</span>.<span style="color:#8e44ad;font-style:italic;">write</span>(<span style="color:#f44f4f;">&quot;i is&quot;</span> + i + <span style="color:#f44f4f;">&quot;&lt;br&gt;&quot;</span>);

<span style="color:#fdbc4b;font-weight:bold;">while</span> (something)
{
  <span style="color:#8e44ad;">block</span>();
  <span style="color:#2980b9;">picky</span>:
    <span style="color:#fdbc4b;font-weight:bold;">if</span> (!<span style="color:#f67400;">1</span>)
      <span style="color:#fdbc4b;font-weight:bold;">break</span>;
    <span style="color:#fdbc4b;font-weight:bold;">else</span>
      <span style="color:#fdbc4b;font-weight:bold;">continue</span>;
}

<span style="color:#fdbc4b;font-weight:bold;">with</span> (a) {
  <span style="color:#fdbc4b;font-weight:bold;">do</span> {
    <span style="color:#8e44ad;">stuff</span>( b ); <span style="color:#7a7c7d;">// a.b if it exists</span>
  } <span style="color:#fdbc4b;font-weight:bold;">while</span> (itmakessense);
}

<span style="color:#fdbc4b;font-weight:bold;">switch</span> (i) {
  <span style="color:#fdbc4b;font-weight:bold;">case</span> <span style="color:#f67400;">0</span>:
  <span style="color:#8e44ad;">f</span>();
  <span style="color:#fdbc4b;font-weight:bold;">break</span>;
  <span style="color:#fdbc4b;font-weight:bold;">default</span>:
  <span style="color:#fdbc4b;font-weight:bold;">break</span>;
}

<span style="color:#7a7c7d;">// Numerics</span>
<span style="font-weight:bold;">var</span> a = <span style="color:#f67400;">0xA</span>;
<span style="font-weight:bold;">var</span> b = <span style="color:#f67400;">0b1</span>;
<span style="font-weight:bold;">var</span> c = <span style="color:#f67400;">0o7</span>;
<span style="font-weight:bold;">var</span> d = <span style="color:#f67400;">1.1E+3</span>;
<span style="font-weight:bold;">var</span> e = <span style="color:#f67400;">1.E+3</span>;
<span style="font-weight:bold;">var</span> f = <span style="color:#f67400;">.1E+3</span>;
<span style="font-weight:bold;">var</span> g = <span style="color:#f67400;">1E+3</span>;
<span style="font-weight:bold;">var</span> h = <span style="color:#f67400;">1.1</span>;
<span style="font-weight:bold;">var</span> i = <span style="color:#f67400;">1.</span>;
<span style="font-weight:bold;">var</span> j = <span style="color:#f67400;">.1</span>;
<span style="font-weight:bold;">var</span> k =  <span style="color:#f67400;">1</span>;
<span style="color:#7a7c7d;">// Bigint</span>
<span style="font-weight:bold;">const</span> binBig = <span style="color:#f67400;">0b101</span>n;
<span style="font-weight:bold;">const</span> octBig = <span style="color:#f67400;">0o567</span>n;
<span style="font-weight:bold;">const</span> hexBig = <span style="color:#f67400;">0xC0B</span>n;
<span style="font-weight:bold;">const</span> decBig = <span style="color:#f67400;">123</span>n;
<span style="color:#7a7c7d;">// Invalid numbers</span>
<span style="font-weight:bold;">var</span> l = <span style="color:#da4453;text-decoration:underline;">0xA1t</span>;
<span style="font-weight:bold;">var</span> m = <span style="color:#da4453;text-decoration:underline;">0b0123</span>;
<span style="font-weight:bold;">var</span> n = <span style="color:#da4453;text-decoration:underline;">0o29</span>;
</pre></body></html>
